<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            list-style: none;
        }

        .box {
            width: 560px;
            height: 300px;
            margin: 100px auto;
            position: relative;
        }

        ul {
            width: 100%;
            height: 100%;
            /* transform: rotate3d(1, 1, 0, -30deg); */
            transform-style: preserve-3d;
        }

        ul li {
            width: 100%;
            height: 20%;
            transform-style: preserve-3d;
            transition: transform 0.5s;
        }

        ul>li>span {
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
        }

        ul>li>span:nth-of-type(1) {
            background: url("images/q1.jpg");
            /*往z轴正方向偏移*/
            transform: translateZ(280px);
        }

        ul>li>span:nth-of-type(2) {
            background: url("images/q4.jpg");
            transform: translateX(-280px) rotateY(-90deg)
        }

        ul>li>span:nth-of-type(3) {
            background: url("images/q3.jpg");
            transform: translateZ(-280px) rotateY(180deg);
        }

        ul>li>span:nth-of-type(4) {
            background: url("images/q2.jpg");
            transform: translateX(280px) rotateY(90deg)
        }

        ul li:nth-of-type(2) span {
            background-position: 0 -100%;
        }

        ul li:nth-of-type(3) span {
            background-position: 0 -200%;
        }

        ul li:nth-of-type(4) span {
            background-position: 0 -300%;
        }

        ul li:nth-of-type(5) span {
            background-position: 0 -400%;
        }

        .pre,
        .next {
            width: 60px;
            height: 60px;
            text-align: center;
            line-height: 60px;
            position: absolute;
            top: 50%;
            text-decoration: none;
            font-size: 40px;
            transform: translate(0, -50%);
            background-color: rgba(0, 0, 0, 0.5);
            color: #fff;
        }

        .pre {
            left: 0;
        }

        .next {
            right: 0;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li>
                <span></span>
                <span></span>
                <span></span>
                <span></span>
            </li>
            <li>
                <span></span>
                <span></span>
                <span></span>
                <span></span>
            </li>
            <li>
                <span></span>
                <span></span>
                <span></span>
                <span></span>
            </li>
            <li>
                <span></span>
                <span></span>
                <span></span>
                <span></span>
            </li>
            <li>
                <span></span>
                <span></span>
                <span></span>
                <span></span>
            </li>
        </ul>
        <a href="javascript:;" class="pre">&lt;</a>
        <a href="javascript:;" class="next">&gt;</a>
    </div>
    <script src="js/jquery.min.js"></script>
    <script>
        $(function () {
            var index = 0;
            var flag = true;
            // 下一张
            $(".next").on("click", function () {
                if (flag) {
                    flag = false;
                    index--;
                    $("li").each(function (key, value) {
                        $(this).css({
                            "transform": "rotateY(" + (index * 90) + "deg)",
                            "transition-delay": (key * 0.2) + "s"
                        });
                    });
                    setTimeout(function () {
                        flag = true;
                    }, 1000);
                }
            })
            // 上一张
            $(".pre").on("click", function () {
                if (flag) {
                    flag = false;
                    index++;
                    $("li").each(function (key, value) {
                        $(this).css({
                            "transform": "rotateY(" + (index * 90) + "deg)",
                            "transition-delay": (key * 0.2) + "s"
                        });
                    });
                    setTimeout(function () {
                        flag = true;
                    }, 1000);
                }
            })
        });
    </script>
</body>

</html>